package com.atguigu.spyx.model.common;

import lombok.Data;

/**
 * @author LT
 * @create 2023-10-31-19:07
 */
@Data
public class Result<T> {

    private Integer code;
    private String message;
    private T data;

    public static <T> Result<T> ok(){
        return Result.setResult(ResultCodeEnum.SUCCESS);
    }
    public static <T> Result<T> fail(){
        return Result.setResult(ResultCodeEnum.ERROR);
    }
    public static <T> Result<T> setResult(ResultCodeEnum codeEnum){
        Result result= new Result();
        result.code=codeEnum.getCode();
        result.message=codeEnum.getMessage();
        return result;
    }
    public Result<T> code(Integer code){
        this.code=code;
        return this;
    }
    public Result<T> message(String message){
        this.message=message;
        return this;
    }
    public Result<T> data(T data){
        this.data=data;
        return this;
    }


}
